//
//  ViewController.m
//  水波纹
//
//  Created by bia一下 on 2017/4/19.
//  Copyright © 2017年 bia一下. All rights reserved.
//

#import "ViewController.h"
#import "WaterGrainView.h"
#import "NextViewController.h"

@interface ViewController ()
{
    WaterGrainView *view;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view setBackgroundColor:[UIColor greenColor]];
    
    view = [[WaterGrainView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) lineColor:[UIColor redColor] lineWidth:3.0];
    view.center = self.view.center;
    view.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view];
    // Do any additional setup after loading the view, typically from a nib.
    
    UIButton *presentButton = [[UIButton alloc] initWithFrame:CGRectZero];
    [presentButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [presentButton setTitle:@"返回" forState:UIControlStateNormal];
    [presentButton sizeToFit];
    [presentButton setCenter:view.center];
    [presentButton addTarget:self action:@selector(presentButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:presentButton];
}

-(void)presentButtonAction:(UIButton *)sender
{
    [self presentViewController:[[NextViewController alloc] init] animated:YES completion:nil];
}


-(void)viewWillAppear:(BOOL)animated
{
    [view setNeedsDisplay];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
